﻿
@{
    ViewBag.Title = "油机详情";
}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>中国铁塔油机管理系统-@ViewBag.Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="~/Content/css/frozenui.css">
    <link rel="stylesheet" href="~/Content/css/style.css">
    <link rel="stylesheet" href="~/Content/css/swiper.min.css">
    <link href="~/Content/css/aui.css" rel="stylesheet" />
    <link href="~/Content/css/weui.1.1.2min.css" rel="stylesheet" />
    <link rel="stylesheet" href="~/Content/css/weui.min.css">
    <link rel="stylesheet" href="~/Content/css/jquery-weui.min.css">
    <script src="~/Content/script/jquery-3.3.1.min.js"></script>
    <script src="~/Content/script/jquery-1.11.0.min.js"></script>
    <script src="~/Content/script/jquery-weui-1.2.1.min.js"></script>
    <script src="~/Content/script/weui1.1.3.min.js"></script>
    <script src="~/Content/script/swiper.min.js"></script>

    <script src="~/Content/script/Uitls.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        html, body {
            position: relative;
            height: 100%;
        }

        li, a {
            list-style: none;
            text-decoration: none;
        }

        .swiper-container {
            width: 100%;
        }

        #nav {
            background: #fff;
        }

            #nav .swiper-wrapper {
                box-sizing: border-box;
                margin: 0;
                line-height: 1.6rem;
            }

            #nav li {
                text-align: center;
                color: #424242;
                font-size: 0.63rem;
            }

                #nav li span {
                    color: #3597D9;
                }

            #nav .active-nav {
                color: #2ECA70;
                border-bottom: 2px solid #2ECA70;
            }

                #nav .active-nav span {
                    color: #2ECA70;
                }



        #page {
            position: absolute;
            top: 1.68rem;
            left: 0;
            right: 0;
            bottom: 1.6rem;
            overflow: hidden;
        }

            #page .swiper-slide {
                text-align: center;
                overflow-y: scroll;
                position: relative;
                padding-top: 5px;
                box-sizing: border-box;
            }

        #tableHeader {
            height: 1.6rem;
        }

            #tableHeader table {
                width: 100%;
                height: 1.6rem;
                color: #fff;
                font-size: 0.6rem;
            }

                #tableHeader table tr th {
                    text-align: center;
                }

                #tableHeader table th:nth-child(even) {
                    background: #4FC2A1;
                }

                #tableHeader table th:nth-child(odd) {
                    background: #334960;
                }

        #content {
            position: absolute;
            top: 1.6rem;
            left: 0;
            right: 0;
            bottom: 0;
            overflow-y: scroll;
        }

        #page table {
            background: #fff;
            width: 100%;
        }

            #page table tr:nth-child(even) {
                background: #F8F8F8;
            }

        #page tr td {
            font-size: 0.64rem;
            color: #000;
            padding: 10px 0;
            font-family: "微软雅黑";
        }

            #page tr td:nth-child(1), #page tr td:nth-child(2) {
                width: 30%;
            }

            #page tr td:nth-child(3), #page tr td:nth-child(4) {
                width: 20%;
            }

        #footer {
            position: absolute;
            height: 1.6rem;
            left: 0;
            right: 0;
            bottom: 0;
            padding: 0;
            margin: 0;
            background-color: #00bcd4;
        }

            #footer .ui-btn-primary {
                height: 1.6rem;
                width: 100%;
                line-height: 1.6rem;
                font-size: 0.68rem;
            }
    </style>
</head>
<body>



    <div id="nav" class="swiper-container">
        <ul class="swiper-wrapper">
            <li class="swiper-slide active-nav">参数一</li>
            <li class="swiper-slide">参数二</li>
            <li class="swiper-slide">参数三</li>
        </ul>
    </div>

    <div class="swiper-container" id="page">
        <div class="swiper-wrapper">
            <div class="swiper-slide slidepage">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>采集器ID:</td>
                        <td class="aui-text-info"><span id="dtuId"></span></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>采集器状态:</td>
                        <td class="aui-text-info"><span id="BOnline"></span></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>油机状态:</td>
                        <td class="aui-text-info"><span id="bRunning"></span></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>市电频率:</td>
                        <td class="aui-text-info">
                            <span id="MAINFREQ"></span>
                        </td>
                        <td>Hz</td>
                    </tr>
                    <tr>
                        <td>市电电压:</td>
                        <td class="aui-text-info"><span id="MAINVOLT"></span></td>
                        <td>V</td>
                    </tr>
                    <tr>
                        <td>空载/待载:</td>
                        <td class="aui-text-info"><span id="UnRunningPeriod"></span> / <span id="RunningPeriod"></span></td>
                        <td>H</td>
                    </tr>
                    <tr>
                        <td>发电电量:</td>
                        <td class="aui-text-info"><span id="KWpower"></span></td>
                        <td>Kw.H</td>
                    </tr>
                    <tr>
                        <td>发电频率:</td>
                        <td class="aui-text-info"><span id="GENFREQ"></span></td>
                        <td>Hz</td>
                    </tr>
                    <tr>
                        <td>基站名称:</td>
                        <td class="aui-text-info"><span id="BaseStationName" style="width:300px" hidden="hidden"></span></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>疑似市电:</td>
                        <td class="aui-text-info"><span id="SEEMINGMAIN"></span></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>信号强度:</td>
                        <td class="aui-text-info"><span id="CSQ"></span></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>运行状态:</td>
                        <td class="aui-text-info"><span id="bRunning"></span></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>报警信息:</td>
                        <td class="aui-text-info">
                            <span id="Alarms" style="width:300px"></span>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>启动时间:</td>
                        <td class="aui-text-info">
                            <span id="GenStart"></span>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>停机时间:</td>
                        <td class="aui-text-info">
                            <span id="GenStop"></span>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>日期时间:</td>
                        <td class="aui-text-info">
                            <span id="DATECLOCK"></span>
                        </td>
                        <td></td>
                    </tr>
                </table>
            </div>
            <div class="swiper-slide slidepage">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>发电电压L1:</td>
                        <td class="aui-text-info"><span id="GENVOLTL1"></span></td>
                        <td>V</td>
                    </tr>
                    <tr>
                        <td>发电电压L2:</td>
                        <td class="aui-text-info"><span id="GENVOLTL2"></span></td>
                        <td>V</td>
                    </tr>
                    <tr>
                        <td>发电电压L3:</td>
                        <td class="aui-text-info"><span id="GENVOLTL3"></span></td>
                        <td>V</td>
                    </tr>
                    <tr>
                        <td>发电电压L12:</td>
                        <td class="aui-text-info"><span id="GENVOLTL12"></span></td>
                        <td>V</td>
                    </tr>
                    <tr>
                        <td>发电电压L23:</td>
                        <td class="aui-text-info"><span id="GENVOLTL23"></span></td>
                        <td>V</td>
                    </tr>
                    <tr>
                        <td>发电电压L31:</td>
                        <td class="aui-text-info"><span id="GENVOLTL31"></span></td>
                        <td>V</td>
                    </tr>
                    <tr>
                        <td>发电电流L1:</td>
                        <td class="aui-text-info"><span id="GENCURRENTL1"></span></td>
                        <td>A</td>
                    </tr>
                    <tr>
                        <td>发电电流L2:</td>
                        <td class="aui-text-info"><span id="GENCURRENTL2"></span></td>
                        <td>A</td>
                    </tr>
                    <tr>
                        <td>发电电流L3:</td>
                        <td class="aui-text-info"><span id="GENCURRENTL3"></span></td>
                        <td>A</td>
                    </tr>
                    <tr>
                        <td>发电总电流:</td>
                        <td class="aui-text-info"><span id="TOTCURRENT"></span></td>
                        <td>A</td>
                    </tr>
                    <tr>
                        <td>有功功率:</td>
                        <td class="aui-text-info">
                            <span id="ACTIVEPOWER"></span>
                        </td>
                        <td>Kw</td>
                    </tr>
                    <tr>
                        <td>无功功率:</td>
                        <td class="aui-text-info">
                            <span id="REACTIVEPOWER"></span>
                        </td>
                        <td>KVAR</td>
                    </tr>
                    <tr>
                        <td>视在功率:</td>
                        <td class="aui-text-info">
                            <span id="APPARENTPOWER"></span>
                        </td>
                        <td>KVA</td>
                    </tr>
                    <tr>
                        <td>功率因数:</td>
                        <td class="aui-text-info">
                            <span id="POWERFACTOR"></span>
                        </td>
                        <td></td>
                    </tr>
                </table>
            </div>
            <div class="swiper-slide slidepage">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>蓄电池电压:</td>
                        <td class="aui-text-info"><span id="ExtBATVolt"></span></td>
                        <td>V</td>
                    </tr>
                    <tr>
                        <td>锂电池电压:</td>
                        <td class="aui-text-info"><span id="LiBATVolt"></span></td>
                        <td>V</td>
                    </tr>
                    <tr>
                        <td>锂电池低压报警:</td>
                        <td class="aui-text-info"><span id="BATLOWVOLTALARM"></span></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>输入口1电压:</td>
                        <td class="aui-text-info"><span id="INPUT1VOLT"></span></td>
                        <td>mV</td>
                    </tr>
                    <tr>
                        <td>输入口2电压:</td>
                        <td class="aui-text-info"><span id="INPUT2VOLT"></span></td>
                        <td>mV</td>
                    </tr>
                    <tr>
                        <td>输入口3电压:</td>
                        <td class="aui-text-info"><span id="INPUT3VOLT"></span></td>
                        <td>mV</td>
                    </tr>
                    <tr>
                        <td>继电器1输出:</td>
                        <td class="aui-text-info"><span id="RELAY1STATUS"></span></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>继电器2输出:</td>
                        <td class="aui-text-info"><span id="RELAY2STATUS"></span></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>继电器3输出:</td>
                        <td class="aui-text-info"><span id="RELAY3STATUS"></span></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>继电器4输出:</td>
                        <td class="aui-text-info"><span id="RELAY4STATUS"></span></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>余油量(升):</td>
                        <td class="aui-text-info">
                            <span id="LastFuelValue"></span>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>余油发电时长:</td>
                        <td class="aui-text-info">
                            <span id="FuelDuration"></span>
                        </td>
                        <td>小时(H)</td>
                    </tr>
                    <tr>
                        <td></td>
                        <td class="aui-text-info">
                        </td>
                        <td><button class="aui-text-info" style="background:#03a9f4;" id="openmap"><span style="color:white">查看地图</span></button></td>
                    </tr>
                </table>
            </div>
        </div>
    </div>

    <section class="ui-container actionOne">
        <section id="actionsheet">
            <div class="demo-item">
                <div class="demo-block">
                    <div class="ui-actionsheet" id="actionsheet1">
                        <div class="ui-actionsheet-cnt am-actionsheet-down">
                            <h4>选择操作菜单</h4>
                            @*<button id="EditGenset">编辑油机</button>*@
                            <button id="NewCode">生成二维码</button>
                            @*<button id="GenMainList">油机保养记录</button>*@
                            <button id="GenMainAdd">添加油机保养</button>
                            <button id="GenMaintainAdd">添加采集器维修</button>
                            <button id="GenBracketAdd">增配支架照片</button>
                            <button id="DelGenset">删除油机</button>
                            <div class="ui-actionsheet-split-line"></div>
                            <button id="cancel">取消</button>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </section>

    <div class="ui-btn-wrap" id="footer">
        <button class="ui-btn-primary">
            操作
        </button>
    </div>
    <script src="~/Content/script/jweixin-1.4.0.js"></script>
    <script>
        var dtuid = GetRequest()['dtuid'];//拿到参数dtuid
        var latitude, longitude, GensetNum, GeneratorId;
        getRealData();//初始化
        setInterval(function () {
            getRealData();
        }, 5 * 1000);//5秒实时刷新



        //获取Detail传过来的参数
        function GetRequest() {
            var url = location.search; //获取url中"?"符后的字串
            var theRequest = new Object();
            if (url.indexOf("?") != -1) {
                var str = url.substr(1);
                strs = str.split("&");
                for (var i = 0; i < strs.length; i++) {
                    theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
                }
            }
            return theRequest;
        }



        (function (designWidth, maxWidth) {
            var html = document.getElementsByTagName("html")[0];
            var tid;
            function refreshRem() {
                var width = html.getBoundingClientRect().width;
                html.style.fontSize = width / 15 + "px"
            }
            window.addEventListener("resize", function () {
                clearTimeout(tid); //防止执行两次
                tid = setTimeout(refreshRem, 300);
            }, false);
            refreshRem();
        })();


        (function (doc, win) {

            var size = 10;
            var myNav = new Swiper('#nav', {
                spaceBetween: 10,
                slidesPerView: 3,//控制单屏显示的slider的数量
                watchSlidesProgress: true,
                watchSlidesVisibility: true,
                on: {
                    tap: function () {
                        myPage.slideTo(myNav.clickedIndex)
                    }
                }
            });

            var myPage = new Swiper('#page', {
                on: {
                    slideChangeTransitionStart: function () {
                        updateNavPosition()
                    }
                }
            });

            function updateNavPosition() {
                $('#nav .active-nav').removeClass('active-nav');
                var activeNav = $('#nav .swiper-slide').eq(myPage.activeIndex).addClass('active-nav');
                if (!activeNav.hasClass('swiper-slide-visible')) {

                    if (activeNav.index() >= myNav.activeIndex) {
                        var thumbsPerNav = Math.floor(myNav.width / activeNav.width()) - 1
                        myNav.slideTo(activeNav.index() - thumbsPerNav)
                    } else {
                        myNav.slideTo(activeNav.index())
                    }
                }
            }

            $("#NewCode").click(function () {
                window.location.href = "https://api.pwmqr.com/qrcode/create/?url=" + dtuid;
            })

            $("#footer").click(function () {
                $('.ui-actionsheet').addClass('show');

            });

            $("#cancel").click(function () {
                $(".ui-actionsheet").removeClass("show");
            });

            $("#goBack").click(function () {

                window.history.back()
            })

            //$("#GenMainList").click(function () {
            //    window.location.href = "/GenMain/AddGenMain?dtuid=" + dtuid;
            //})
            $("#GenMainAdd").click(function () {
                window.location.href = "/GenMain/AddGenMain?dtuid=" + dtuid;
            })
            ;
            $("#GenMaintainAdd").click(function () {
                window.location.href = "/Maintain/AddGenMaintain?dtuid=" + dtuid;
            });
            $("#GenBracketAdd").click(function () {
                window.location.href = "/Bracket/AddGenBracket?dtuid=" + dtuid;
            });



        })(document, window);


        //微信jdk
        $.ajax({
            url: '/WeiXin/JsapiTicketSignature?fullUrl=' + window.location.href + '',
            type: 'get',
            //beforeSend: function () {
            //    $.showLoading("加载中...");
            //},
            success: function (data) {
                //$.hideLoading();
                var result = eval(data);
                console.log(data)
                console.log(result)
                // wx.config成功后才会触发wx.ready
                wx.config({
                    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                    appId: result.appId, // 必填，公众号的唯一标识
                    timestamp: result.timestamp, // 必填，生成签名的时间戳
                    nonceStr: result.nonceStr, // 必填，生成签名的随机串
                    signature: result.signature,// 必填，签名
                    jsApiList: ["JSAPI","openLocation", "getLocation"] // 必填，需要使用的JS接口列表
                });
            }
        });
        wx.ready(function () {
            $("#openmap").click(function () {
                console.log("openmap")
                wx.openLocation({
                    latitude: parseFloat(wgs84togcj02(longitude, latitude)[1]), // 纬度，浮点数，范围为90 ~ -90
                    longitude: parseFloat(wgs84togcj02(longitude, latitude)[0]), // 经度，浮点数，范围为180 ~ -180。
                    name: '油机位置', // 位置名
                    address: '油机编号:' + GensetNum, // 地址详情说明
                    scale: 16, // 地图缩放级别,整形值,范围从1~28。默认为最大
                    infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
                });
            })

        })


        //GPS坐标转火星坐标   用于腾讯地图
        var x_PI = 3.14159265358979324 * 3000.0 / 180.0;
        var PI = 3.1415926535897932384626;
        var a = 6378245.0;
        var ee = 0.00669342162296594323;

        function wgs84togcj02(lng, lat) {
            if (out_of_china(lng, lat)) {
                return [lng, lat]
            }
            else {
                var dlat = transformlat(lng - 105.0, lat - 35.0);
                var dlng = transformlng(lng - 105.0, lat - 35.0);
                var radlat = lat / 180.0 * PI;
                var magic = Math.sin(radlat);
                magic = 1 - ee * magic * magic;
                var sqrtmagic = Math.sqrt(magic);
                dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
                dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
                var mglat = lat + dlat;
                var mglng = lng + dlng;
                return [mglng, mglat]
            }
        }


        @*/**
            * 判断是否在国内，不在国内则不做偏移
            * @param lng
            * @param lat
            * @returns {boolean}
        */*@
        function out_of_china(lng, lat) {
            return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false);
        }

        function transformlat(lng, lat) {
            var ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
            ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
            ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0;
            ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0;
            return ret
        }

        function transformlng(lng, lat) {
            var ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
            ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
            ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0;
            ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0;
            return ret

        }

        //实时获取数据
        function getRealData() {
            try {
                $.ajax({
                    //url: '/api/Generator/realData?dtuId=' + dtuid + '',
                    url: '/api/Generator/realData',
                    type: 'get',
                    data: { dtuId: dtuid },
                    success: function (data) {
                        //var res = JSON.parse(data);
                        var res = data.Data;
                        console.log(res)
                        if (res && res.g) {
                            GeneratorId = res.g.GeneratorId;//全局变量 便于删除油机
                        }
                        if (res && res.c) {
                            $("#dtuId").text(res.c.DTUID);
                            $("#BOnline").text(res.c.BOnline ? "在线" : "离线");
                            $("#bRunning").text(res.c.BOnline ? "运行" : "")
                            $('#MAINFREQ').text(res.c.MAINFREQ ? res.c.MAINFREQ : '');
                            $('#MAINVOLT').text(res.c.MAINVOLT ? res.c.MAINVOLT : '');
                            $('#GENFREQ').text(res.c.GENFREQ ? res.c.GENFREQ : '');
                            $('#GENVOLTL1').text(!res.c.BOnline ? '' : res.c.GENVOLTL1 ? utilss.formatNumber(res.c.GENVOLTL1, '0.0') : '');
                            $('#GENVOLTL2').text(!res.c.BOnline ? '' : res.c.GENVOLTL2 ? utilss.formatNumber(res.c.GENVOLTL2, '0.0') : '');
                            $('#GENVOLTL3').text(!res.c.BOnline ? '' : res.c.GENVOLTL3 ? utilss.formatNumber(res.c.GENVOLTL3, '0.0') : '');
                            $('#GENVOLTL12').text(!res.c.BOnline ? '' : res.c.GENVOLTL12 ? res.c.GENVOLTL12 : '');
                            $('#GENVOLTL23').text(!res.c.BOnline ? '' : res.c.GENVOLTL23 ? res.c.GENVOLTL23 : '');
                            $('#GENVOLTL31').text(!res.c.BOnline ? '' : res.c.GENVOLTL31 ? res.c.GENVOLTL31 : '');
                            $('#GENCURRENTL1').text(!res.c.BOnline ? '' : res.c.GENCURRENTL1 ? res.c.GENCURRENTL1 : '');
                            $('#GENCURRENTL2').text(!res.c.BOnline ? '' : res.c.GENCURRENTL2 ? res.c.GENCURRENTL2 : '');
                            $('#GENCURRENTL3').text(!res.c.BOnline ? '' : res.c.GENCURRENTL3 ? res.c.GENCURRENTL3 : '');
                            $('#TOTCURRENT').text(res.c.TOTCURRENT ? res.c.TOTCURRENT : '');
                            $('#GENPHASEL12').text(res.c.GENPHASEL12 ? res.c.GENPHASEL12 : '');
                            $('#GENPHASEL13').text(res.c.GENPHASEL13 ? res.c.GENPHASEL13 : '');
                            $('#ACTIVEPOWER').text(res.c.ACTIVEPOWER ? res.c.ACTIVEPOWER : '');
                            $('#REACTIVEPOWER').text(res.c.REACTIVEPOWER ? res.c.REACTIVEPOWER : '');
                            $('#APPARENTPOWER').text(res.c.APPARENTPOWER ? res.c.APPARENTPOWER : '');
                            $('#POWERFACTOR').text(res.c.POWERFACTOR ? res.c.POWERFACTOR : '');
                            $('#ExtBATVolt').text(res.c.ExtBATVolt ? res.c.ExtBATVolt : '');
                            $('#LiBATVolt').text(res.c.LiBATVolt ? res.c.LiBATVolt : '');
                            $('#INPUT1VOLT').text(res.c.INPUT1VOLT ? res.c.INPUT1VOLT : '');
                            $('#INPUT2VOLT').text(res.c.INPUT2VOLT ? res.c.INPUT2VOLT : '');
                            $('#INPUT3VOLT').text(res.c.INPUT3VOLT ? res.c.INPUT3VOLT : '');
                            $('#RELAY1STATUS').text(res.c.RELAY1STATUS ? 'Close' : 'Open');
                            $('#RELAY2STATUS').text(res.c.RELAY2STATUS ? 'Close' : 'Open');
                            $('#RELAY3STATUS').text(res.c.RELAY3STATUS ? 'Close' : 'Open');
                            $('#RELAY4STATUS').text(res.c.RELAY4STATUS ? 'Close' : 'Open');
                            $('#LastFuelValue').text(res.c.LastFuelValue ? utilss.formatNumber(res.c.LastFuelValue, '0.00') : '0.00');
                            $('#FuelDuration').text(res.c.FuelDuration ? utilss.formatNumber(res.c.FuelDuration, '0.00') : '0.00');

                            $('#SEEMINGMAIN').text(res.c.SEEMINGMAIN ? 'Yes' : 'No');
                            $('#DATECLOCK').text(res.c.DATECLOCK && res.c.DATECLOCK !== "" ? utilss.formatDate(res.c.DATECLOCK, 'yyyy-MM-dd hh:mm:ss') : '');
                            $('#GenStart').text(res.c.GenStart && res.c.GenStart !== "" ? utilss.formatDate(res.c.GenStart, 'yyyy-MM-dd hh:mm:ss') : '');
                            $('#GenStop').text(res.c.GenStop && res.c.GenStop !== "" ? utilss.formatDate(res.c.GenStop, 'yyyy-MM-dd hh:mm:ss') : '');
                            $('#RunningPeriod').text(res.c.RunningPeriod ? utilss.formatNumber(res.c.RunningPeriod, '0.00') : '');
                            var genstar = Date.parse(utilss.formatDate(res.c.GenStart, 'yyyy/MM/dd hh:mm:ss'));
                            var genstop = Date.parse(utilss.formatDate(res.c.GenStop, 'yyyy/MM/dd hh:mm:ss'));
                            if ($('#RunningPeriod').text() !== "" && $('#RunningPeriod').text() !== null) {
                                var unRunningPeriod = ((genstop - genstar) / (1000 * 60 * 60)) - $('#RunningPeriod').text();//计算空载时长
                                unRunningPeriod = unRunningPeriod ? unRunningPeriod.toFixed(2) : '0.00';//取2位小数
                                $('#UnRunningPeriod').text(unRunningPeriod <= 0 ? '0.00' : unRunningPeriod);//修正空载时长，下于0时则未0;
                            }
                            $('#KWpower').text(res.c.KWpower ? res.c.KWpower : '');
                            $('#bRunning').text(res.c.bRunning ? 'Yes' : 'No');
                            $('#LAC').text(res.c.LAC ? res.c.LAC : '');
                            $('#CellID').text(res.c.CellID ? res.c.CellID : '');
                            $('#LACCID').text((res.c.LAC ? res.c.LAC : '') + ',' + (res.c.CellID ? res.c.CellID : ''));
                            $('#BaseStationName').text(res.c.BaseStationName && res.c.BaseStationName !== '' ? res.c.BaseStationName : 'lac:' + res.c.LAC + ',cid:' + res.c.CellID);
                            $('#BATLOWVOLTALARM').text(res.c.BATLOWVOLTALARM ? 'Yes' : 'No');
                            $('#CSQ').text(res.c.CSQ ? res.c.CSQ : '');
                            $('#Alarms').text(res.c.Alarms ? res.c.Alarms : '');
                            latitude = res.c.GPSLocLat;
                            longitude = res.c.GPSLocLgt;
                            GensetNum = res.c.GensetNum;
                        }
                    }
                });

            }
            catch (e) {
                setTimeout(function () {
                    getRealData();
                }, 3000);
            }
        };


        //删除
        $("#DelGenset").click(function () {
            $(".ui-actionsheet").removeClass("show");
            //if (confirm("是否执行此操作?")) {

            //}
            $.confirm("是否执行此操作?", "提示", function () {
                $.ajax({
                    url: '/api/Generator/DeleteGen?GeneratorId=' + GeneratorId + '',
                    type: 'get',
                    success: function (data) {
                        var res = data.Data;
                        //var res = JSON.parse(data);
                        if (res.Code > 0) {
                            $.toast("删除成功!");
                            setTimeout(function () {
                                location.href = "/Generator/Index";
                            }, 1 * 1000);
                        } else {
                            $.alert(res.Result, "提示");
                            return;
                        }
                    }
                }
	            );
            }, function () {

            })
        })

        //绑定发电机事件
        $("#bindGenset").click(function () {
            location.href = "/AnnouceList/BinGenset?annouceCode=" + $("#annouceCode").html() + "";
        });

        //返回列表
        $("#returnList").click(function () {
            location.href = "/AnnouceList/Index";
        });
    </script>
</body>
</html>
